package fm.last.time.stats;

import java.util.concurrent.ExecutionException;

import org.json.JSONException;
import org.json.JSONObject;

import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.format.Time;
import arnodenhond.graphviewdemo.GraphView;

public class showTimeOfDayStats extends Activity {
    private static final String API_KEY = "04b02282f283255d4429f0650332c8cf";
	private static final String user_me = "firemanphil1";

	/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
    	super.onCreate(savedInstanceState);
    	new AuthenticationRequester().execute(user_me,"francesca",
    			API_KEY, "5542ec82e2d09b59dc5cd7154b21859c");
		Time time = new Time();
		time.set(1, 1, 2011);
		Long beginningOfYear = time.toMillis(false);
    	AsyncTask<String, Integer, String> recentTracksTask = new RecentTracksRequester().execute(user_me, "1", Long.toString(System.currentTimeMillis()),
    			Long.toString(beginningOfYear), API_KEY);
    	String recentTracksResult;
    	try {
			recentTracksResult = recentTracksTask.get();
			JSONObject obj = new JSONObject(recentTracksResult);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return;
		} catch (ExecutionException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return;
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return;
		}
    	float[] values = new float[] { 2.0f,1.5f, 2.5f, 1.0f , 3.0f };
		String[] verlabels = new String[] { "great", "ok", "bad" };
		String[] horlabels = new String[] { "today", "tomorrow", "next week", "next month" };
		GraphView graphView = new GraphView(this, values, "GraphViewDemo",horlabels, verlabels, GraphView.BAR);
		setContentView(graphView);
    }
}